package com.zhengqing.app.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhengqing.app.entity.Test;
import com.zhengqing.app.mapper.TestMapper;
import com.zhengqing.app.model.dto.TestPageDTO;
import com.zhengqing.app.model.dto.TestSaveDTO;
import com.zhengqing.app.model.vo.TestPageVO;
import com.zhengqing.app.service.ITestService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * <p> 测试 服务实现类 </p>
 *
 * @author zhengqingya
 * @description
 * @date 2024/5/13 15:26
 */
@Service
@RequiredArgsConstructor
public class TestServiceImpl extends ServiceImpl<TestMapper, Test> implements ITestService {

    private final TestMapper testMapper;

    @Override
    public IPage<TestPageVO> page(TestPageDTO params) {
        return this.testMapper.page(new Page<>(params.getPageNum(), params.getPageSize()), params);
    }

    @Override
    public void addOrUpdateData(TestSaveDTO params) {
        Test test = Test.builder()
                .id(params.getId())
                .name(params.getName())
                .createTime(params.getCreateTime())
                .build();
        super.saveOrUpdate(test);
    }


}
